package components;

import exceptions.NotInValidStateException;

public class Drum {

	protected int maxLoad;
	private int load;
	private boolean areDoorsClosed;
	
	public void increaseLoad() {
		load = load + 1;
	}

	public int getLoad() {
		return load;
	}

	public void setLoad(int load) {
		this.load = load;
	}
	
	public boolean areDoorsClosed() {
		return areDoorsClosed;
	}

	public void setDoorsClosed(boolean areDoorsClosed) {

		if (this.areDoorsClosed != areDoorsClosed) {
			if (this.areDoorsClosed) {
				throw new NotInValidStateException(
						"Washing machine is working. Cannot open doors now!");
			} else {
				this.areDoorsClosed = areDoorsClosed;
			}

		} else {
			String doorsStatus;
			if (this.areDoorsClosed) {
				doorsStatus = "closed";
			} else {
				doorsStatus = "opened";
			}
			throw new NotInValidStateException("Doors already are "
					+ doorsStatus + "!");
		}

	}

}
